/**
 * 
 */
package com.jeecms.wicool.manager.shops.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jeecms.cms.entity.main.CmsUser;
import com.jeecms.common.hibernate3.Updater;
import com.jeecms.common.page.Pagination;
import com.jeecms.wicool.dao.shops.ScoreShareSetDao;
import com.jeecms.wicool.entity.shops.ScoreShareSet;
import com.jeecms.wicool.entity.shops.ShopInfo;
import com.jeecms.wicool.manager.shops.ScoreShareSetMng;
import com.jeecms.wicool.manager.shops.WiShopInfoMng;

/**
 * @author spring
 *
 */
@Service
@Transactional
public class ScoreShareSetMngImpl implements ScoreShareSetMng {
	
	@Autowired
	private ScoreShareSetDao scoreShareSetDao;
	
	@Autowired
	private WiShopInfoMng shopMng;

	@Override
	public Pagination getPage(int pageNo, int pageSize, CmsUser user) {
		return scoreShareSetDao.getPage(pageNo, pageSize, user);
	}

	@Override
	public ScoreShareSet findById(Integer id) {
		return scoreShareSetDao.findById(id);
	}

	@Override
	public ScoreShareSet save(ScoreShareSet bean, Integer shopId) {
		ShopInfo shop = shopMng.findById(shopId);
		bean.setShop(shop);
		return scoreShareSetDao.save(bean);
	}

	@Override
	public ScoreShareSet update(ScoreShareSet bean, Integer shopId) {
		ShopInfo shop = shopMng.findById(shopId);
		bean.setShop(shop);
		Updater<ScoreShareSet> updater = new Updater<ScoreShareSet>(bean);
		return scoreShareSetDao.updateByUpdater(updater);
	}

	@Override
	public ScoreShareSet deleteById(Integer id) {
		return scoreShareSetDao.deleteById(id);
	}

	@Override
	public ScoreShareSet[] deleteByIds(Integer[] ids) {
		ScoreShareSet[] beans = new ScoreShareSet[ids.length];
		for (int i = 0; i < ids.length; i++) {
			beans[i] = deleteById(ids[i]);
		}
		return beans;
	}

}
